﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="serviceTypeUC.ascx.cs" Inherits="MobiMap.Admin.serviceTypeUC" %>

<link rel="Stylesheet" href="../Style/AdminStyle.css" type="text/css" />
<script type="text/javascript">
    function ShowInfo(id, des, path)
    {    
        alert(id + " " + des + " " + path);
        return false;
    }

    function ClickFileDlg(me)
    {
        
        var inputFile = me.parentNode.parentNode.getElementsByTagName("input")[1];
        inputFile.click();
            
        return false;
    }

    function FillPath(me)
    {
        var txtPath = me.parentNode.parentNode.getElementsByTagName("input")[0];
        txtPath.value = me.value;   
    }

    function confirmDelete()
    {
        var confirmMessage = document.getElementById('<%=hddConfirm.ClientID %>').value;
        var answer = confirm(confirmMessage);
        return answer;
    }

    function ShowHideFunctionContent(content1, content2)
    {
        var selectedNode = document.getElementById(content1);
        if(selectedNode.style.display == "none")
        {
            //hien vung content1
            selectedNode.style.display = "block";
            document.getElementById("view" + content1).className = "divVer";
            
            //tat vung content2
            document.getElementById(content2).style.display = "none";
            document.getElementById("view" + content2).className = "divHor";
        }
        else
        {
            selectedNode.style.display = "none";
            document.getElementById("view" + content1).className = "divHor";
        }
    }
    
    function CheckAddPlaceType()
    {
        if(document.getElementById('<%=txtNewDes.ClientID %>').value == "")
            return false;
            
        return true;
    }
    
    function checkUpdate(me)
    {
        var rowNode = (me.parentNode).parentNode;
        var textNode = rowNode.childNodes[1].childNodes[0];
        if(textNode.value == "")
        {
            textNode.style.backgroundColor = "red";
            return false;
        }   
        return true;
    }
</script>

<br />
<div class="divFunction" onclick="ShowHideFunctionContent('add', 'list')">
    <div id="viewadd" class="divHor">
        <asp:Label ID="lbServiceType_Add_Title" runat="server" Text="Add"></asp:Label>
    </div>
</div><br />
<div align="center" id="add" style="display:none;">
    <table cellpadding="2px" cellspacing="0px">
        <tr align="left">
            <td><label id="lbPlaceTypeName" runat="server">Loại dịch vụ</label></td>
            <td><asp:TextBox ID="txtNewDes" runat="server" Width="300px"/></td>
        </tr>
        <tr align="left">
            <td><label id="lbPlaceTypePicture" runat="server">Ảnh minh họa</label></td>
            <td><input type="file" id="filePic" runat="server" size="30"/></td>            
        </tr>
        <tr align="left">
            <td>&nbsp;</td>
            <td><asp:Button ID="btnAddNew" runat="server" CssClass="button" Text="Thêm" OnClientClick="return CheckAddPlaceType();" onclick="btnAddNew_Click"/></td>
        </tr>
    </table>
    <br />
    <div><asp:Label style="color: red;" runat="server" ID="lbMessage" Text=""/></div><br />
</div>


<div class="divFunction" onclick="ShowHideFunctionContent('list', 'add')">
    <div id="viewlist" class="divHor">
        <asp:Label ID="lbServiceType_lstType" runat="server" Text="Danh sách các loại dịch vụ"></asp:Label>
    </div>
</div><br />
<div align="center" id="list" style="display:block;">
    <asp:GridView ID="gvServiceType" runat="server" AutoGenerateColumns="False" 
        CellPadding="2" GridLines="Horizontal" Width="100%" AllowPaging="True" 
        onrowdatabound="gvServiceType_RowDataBound" 
        HorizontalAlign="Left" onpageindexchanging="gvServiceType_PageIndexChanging" 
        OnRowEditing="gvServiceType_RowEditing" OnRowUpdating="gvServiceType_RowUpdating" 
        OnRowCancelingEdit="gvServiceType_RowCancelingEdit" 
        OnRowDeleting="gvServiceType_RowDeleting" DataKeyNames="ID" 
        BorderColor="Black" BorderStyle="Solid" oninit="gvServiceType_Init" 
        PageSize="7">        

    <RowStyle BackColor="White" Height="30px" CssClass="row" HorizontalAlign="Left"/>
    <HeaderStyle HorizontalAlign="Left"/>
    <Columns>  
        <asp:TemplateField>
            <ItemStyle CssClass="idColumn"/>            
            <HeaderTemplate>&nbsp;&nbsp;&nbsp;ID</HeaderTemplate>
            <ItemTemplate>                
                <asp:Label id="lbID" runat ="server" Text='<%# DataBinder.Eval(Container.DataItem, "ID") %>'></asp:Label>                
            </ItemTemplate>   
        </asp:TemplateField>
        <asp:TemplateField>
            <HeaderTemplate>Tên loại dịch vụ</HeaderTemplate>
            <EditItemTemplate>
                <asp:TextBox id="txtDes" runat ="server" Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>'></asp:TextBox>                
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label id="lbDes" runat ="server" Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>'></asp:Label>                
            </ItemTemplate>   
        </asp:TemplateField>
        <asp:TemplateField>
            <HeaderTemplate>Hình ảnh</HeaderTemplate>
            <EditItemTemplate>
                <asp:FileUpload ID="filePicture" runat="server"/>
                <asp:Image ID="imgPic" runat="server" Width="32px" Height="32px"/>                
                <asp:Label Visible="false" id="lbPic" runat ="server" Text='<%# DataBinder.Eval(Container.DataItem, "Picture") %>'></asp:Label>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Image ID="imgPic" runat="server" Width="32px" Height="32px"/>                
                <asp:Label Visible="false" id="lbPic" runat ="server" Text='<%# DataBinder.Eval(Container.DataItem, "Picture") %>'></asp:Label>                
            </ItemTemplate>   
        </asp:TemplateField>
        
        <asp:TemplateField>
            <ItemTemplate>
               <asp:LinkButton Runat="server" CommandName="Edit" ID="lbtEdit" Text="Edit"/>
               <asp:LinkButton Runat="server" ID="lbtDelete" CommandName="Delete" Text="Delete"
                   OnClientClick="return confirmDelete();"/>
           </ItemTemplate>
           <EditItemTemplate>  
               <asp:LinkButton CommandName="Update" ID="lbtUpdate" Text="Update" runat="server"
                    OnClientClick="return checkUpdate(this);"/>      
               <asp:LinkButton CommandName="Cancel" ID="lbtCancel" Text="Cancel" runat="server"/>            
           </EditItemTemplate>
       </asp:TemplateField>
    </Columns>
    <PagerStyle HorizontalAlign="Left" />
    <AlternatingRowStyle BackColor="#E6E6E6" BorderStyle="None" />
</asp:GridView>
    <asp:HiddenField ID="hddConfirm" runat="server" />
</div>
